import Mock from 'mockjs'



function getRandomByStr(l = 3, s) {
    if (typeof s !== 'string') { return }
    var len = +l;
    var chars = '';

    while (len--) {
        chars += s[parseInt(Math.random() * s.length, 10)];
    }
    return chars;
}

function getPlate(total = 9) {
    var en = 'QWERTYUIOPASDFGHJKLZXCVBNM';
    var num = '1234567890';
    var len = +total;
    while (len--) {
        // console.log(`车牌号 ${total - len}：`, getRandomByStr(2, en) + getRandomByStr(3, num));
        return getRandomByStr(2, en) + getRandomByStr(3, num)
    }
}

getPlate();




let paytype = ["微信", "支付宝", "银联", "现金", "pay-pal", "比特币", "现金", "数字人民币"]

let datalist = []

let id = 1;
for (let i = 0; i < 100; i++) {
    let date = Mock.mock('@date()')
    datalist.push({
        id: id++,
        "车牌号": "京" + getPlate(),
        "停车时长": date,
        "入场时间": date + "  " + Mock.mock('@time()'),
        "出场时间": date + "  " + Mock.mock('@time()'),
        "收费员编号": Mock.mock('@zip()'),
        "收费员": Mock.mock('@cname()'),
        "路段编号": Mock.mock('@zip()'),
        "路段地址": Mock.mock('@county(true)'),
        "应收金额": Mock.mock({
            "number|1-100.2": 1
        }).number,
        "支付方式": paytype[Mock.mock({
            "number|0-7": 7
        }).number]
    })
}
let datalist1 = [];

// for (let i = 0; i < 100; i++) {
//     let date = Mock.mock('@date()')
//     datalist1.push([
//          "京" + getPlate(),
//          date,
//          date + "  " + Mock.mock('@time()'),
//          date + "  " + Mock.mock('@time()'),
//          Mock.mock({
//             "number|1-100.2": 1
//         }).number,
//          Mock.mock('@cname()'),
//          Mock.mock('@zip()'),

//          Mock.mock('@zip()'),
//          Mock.mock('@county(true)'),

//          paytype[Mock.mock({
//             "number|0-7": 7
//         }).number]
//     ])
// }


console.log(datalist);